###################################################
## 1、得到pyclone的输入
rm -rf ${Pyclone_path}/Input_all
mkdir -p ${Pyclone_path}/Input_all
for samples in ` cat ${config_path}/tumor_normal.all.list | grep -v Normal` 
do
echo $samples
Tumor=` echo $samples | awk -F, '{print$1}' `
Normal=` echo $samples | awk -F, '{print$2}' `
Class=`cat ${config_path}/tumor_normal.class.list | grep -w ${Tumor} | awk '{print $5}'`
sh ${scripts_path}/pyclone/Pyclone_1_GetInput.sh ${Tumor} ${Normal} ${Class}
done

###################################################
## 2、运行Pyclone
export Type=All
mkdir -p ${Pyclone_path}/result/${Type}
for Normal in ` cat ${config_path}/tumor_normal.all.list | grep -v Normal | awk -F, '{print $2}' | sort -u  | grep -E "585T3" ` 
do
echo " sh ${scripts_path}/pyclone/Pyclone_2_Run.sh ${Normal} ${config_path} ${Type}" | \
qsub -N ${Normal}_"Pyclone" -l nodes=1:ppn=4,mem=10gb,walltime=240:00:00 -q batch -d ${Qsub_log_path}
done

###################################################
## 3、描述克隆聚类
## 同时得到citeup的输入
export Type=All
cat ${config_path}/tumor_normal.list | grep -v Normal | awk -F, '{print $2}' | sort -u | xargs -i -P 6 sh -c '
echo {}
${Rscript} ${scripts_path}/pyclone/Pyclone_3_plot.R \
--work_dir ${work_dir} \
--Sample {} \
--out_dir ${Pyclone_path}/CloneImages \
--loci_file ${Pyclone_path}/result/${Type}/{}/tables/loci.tsv \
--cluster_file ${Pyclone_path}/result/${Type}/{}/tables/cluster.tsv \
--clone_t 0.6 \
--subclone_t 0.2 \
--important_geneList ${work_dir}/public_ref/importTantGene.list
'
